This is an R Markdown document. I can type whatever I want.
This is bold This is italic
echo= false means it won’t show the code chunk, just the output
suppressPackageStartupMessages can be used to wrap around the loading of the tidyverse package so all of those messages don’t appear, for just that line
library(tidyverse)
glimpse(storms)
## Observations: 10,010
## Variables: 13
## $ name <chr> "Amy", "Amy", "Amy", "Amy", "Amy", "Amy", "Amy", "...
## $ year <dbl> 1975, 1975, 1975, 1975, 1975, 1975, 1975, 1975, 19...
## $ month <dbl> 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7,...
## $ day <int> 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30...
## $ hour <dbl> 0, 6, 12, 18, 0, 6, 12, 18, 0, 6, 12, 18, 0, 6, 12...
## $ lat <dbl> 27.5, 28.5, 29.5, 30.5, 31.5, 32.4, 33.3, 34.0, 34...
## $ long <dbl> -79.0, -79.0, -79.0, -79.0, -78.8, -78.7, -78.0, -...
## $ status <chr> "tropical depression", "tropical depression", "tro...
## $ category <ord> -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, ...
## $ wind <int> 25, 25, 25, 25, 25, 25, 25, 30, 35, 40, 45, 50, 50...
## $ pressure <int> 1013, 1013, 1013, 1013, 1012, 1012, 1011, 1006, 10...
## $ ts_diameter <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ hu_diameter <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
library(viridis)
ggplot(storms) +
geom_jitter(aes(as.factor(month), pressure, fill = wind), pch = 21, alpha = 0.05) +
scale_fill_viridis_c() +
theme_bw() +
labs(title = "Hurricane Pressure v Month", subtitle = "with Max Wind Speed", x = "Month")
writing out equations in Rmarkdown
If you want to write an equation, you put a dollar sign on either side of it
\(\sum_{i=y}^n X_i\)
library(knitr)
## Warning: package 'knitr' was built under R version 3.4.4
kable(head(storms), caption = "Table using Kable")
| name | year | month | day | hour | lat | long | status | category | wind | pressure | ts_diameter | hu_diameter |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Amy | 1975 | 6 | 27 | 0 | 27.5 | -79.0 | tropical depression | -1 | 25 | 1013 | NA | NA |
| Amy | 1975 | 6 | 27 | 6 | 28.5 | -79.0 | tropical depression | -1 | 25 | 1013 | NA | NA |
| Amy | 1975 | 6 | 27 | 12 | 29.5 | -79.0 | tropical depression | -1 | 25 | 1013 | NA | NA |
| Amy | 1975 | 6 | 27 | 18 | 30.5 | -79.0 | tropical depression | -1 | 25 | 1013 | NA | NA |
| Amy | 1975 | 6 | 28 | 0 | 31.5 | -78.8 | tropical depression | -1 | 25 | 1012 | NA | NA |
| Amy | 1975 | 6 | 28 | 6 | 32.4 | -78.7 | tropical depression | -1 | 25 | 1012 | NA | NA |
htmlTable::htmlTable(head(storms))
| name | year | month | day | hour | lat | long | status | category | wind | pressure | ts_diameter | hu_diameter | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Amy | 1975 | 6 | 27 | 0 | 27.5 | -79 | tropical depression | -1 | 25 | 1013 | ||
| 2 | Amy | 1975 | 6 | 27 | 6 | 28.5 | -79 | tropical depression | -1 | 25 | 1013 | ||
| 3 | Amy | 1975 | 6 | 27 | 12 | 29.5 | -79 | tropical depression | -1 | 25 | 1013 | ||
| 4 | Amy | 1975 | 6 | 27 | 18 | 30.5 | -79 | tropical depression | -1 | 25 | 1013 | ||
| 5 | Amy | 1975 | 6 | 28 | 0 | 31.5 | -78.8 | tropical depression | -1 | 25 | 1012 | ||
| 6 | Amy | 1975 | 6 | 28 | 6 | 32.4 | -78.7 | tropical depression | -1 | 25 | 1012 |
#make an interactive table
DT::datatable(storms)
library(plotly)
## Warning: package 'plotly' was built under R version 3.4.4
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
ggplotly(
ggplot(storms) +
geom_jitter(aes(as.factor(month), pressure, fill = wind), pch = 21, alpha = 0.05) +
scale_fill_viridis_c() +
theme_bw() +
labs(title = "Hurricane Pressure v Month", subtitle = "with Max Wind Speed", x = "Month"))
## Warning in L$marker$color[idx] <- aes2plotly(data, params, "fill")[idx]:
## number of items to replace is not a multiple of replacement length